package com.lzs.system.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lzs.entity.DictType;
import com.lzs.system.service.DictTypeService;
import com.lzs.util.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 字典类型表 前端控制器
 * </p>
 *
 * @author ymw
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/system/dictType")
public class DictTypeController {
    @Autowired
    private DictTypeService dictTypeService;
    @PostMapping("/selectAllDictTypePage/{page}/{limit}")
    @ApiOperation(value = "字典分页查询")
    public Page<DictType> selectAllDictTypePage(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody DictType dictType){
        Page<DictType> dictTypePage = dictTypeService.selectAllDictTypePage(page, limit,dictType );
        return dictTypePage;
    }
    // 新增修改
    @PostMapping("/insertOrUpdateDictType")
    @ApiOperation(value = "字典新增修改")
    public R insertOrUpdateDictType(@RequestBody DictType dictType){
        return dictTypeService.insertOrUpdateDictType(dictType);
    }
    // 修改时回显内容
    @GetMapping("/findByDictTypeId/{dictTypeId}")
    @ApiOperation(value = "修改时回显内容")
    public R findByDictTypeId(@PathVariable Long dictTypeId){
        return dictTypeService.findByDictTypeId(dictTypeId);
    }
    // 根据Id删除
    @DeleteMapping("/deleteDictType")
    @ApiOperation(value = "根据子典Id删除")
    public R deleteDictType(Long dictTypeId){
        boolean b = dictTypeService.removeById(dictTypeId);
        if (b){
            return R.ok().message("删除成功");
        }
        return R.ok().message("删除失败");
    }
}

